var sockect = {};
function loadInfo(){
    var url = "/app/member/agent/getmsg";
    $.post(url,{r: Math.random()},function(data){
        if(data.status<=0){
            layer.alert(data.info);
            return false;
        }else if(data.status==2){
            layer.alert(data.info);
            window.location.href = "/agent/login.html";
        }else{
            sockect = data.list.socket;
            onAgent(sockect);
            var u_info = data.list.u_info;
            if (!IsNull(u_info)) {
                $(".username").html(u_info.username);
                $(".balance").html(u_info.money);
                $("#login_time").html("上次登陆："+u_info.login_time);
            }
        }
    },"json");
}
loadInfo();




//判断变量为空
function IsNull(args){
    for(var n in args){return false} 
    return true; 
}


function salfOut(){
    $.post("/app/member/index/loginOut",{t:Math.random()},function(data){
        if(data.status<=0){
            layer.alert(data.info);
            return false;
        }else{
            window.location.href="/agent/login.html";
        }
    },"json");
    
}


function checkUrl(kcurl){
    $.ajaxSetup({async: false}); 
    var surl ="";
    $.post("/app/member/access/set_sign_http",{kcurl:kcurl},function(data){
        if(data.status<=0){
                layer.alert(data.info);
                return false;
            }else{
                surl = String(data.info);
            }
    },"json");
    return surl;
}

/*
 * 去尾保留两位小数
 */
function getTwoFloor(num) {
    num = String(num);
        var arr = num.split(".");
        if (arr.length > 1) {
            arr[0] = parseInt(arr[0], 10) || 0;
            if (arr[1].length >= 2) {
                arr[1] = String(arr[1]).substr(0, 2);
            } else {
                arr[1] = arr[1] + '0';
            }
            rs = arr.join('.');
        }else{
        rs = parseInt(num)+'.00';
    }
    return rs;
}

function goIndex(){
    window.location.href = "index.html";
}